package com.wmada.spring.api;

import org.springframework.http.HttpStatus;

/**
 * @author will.ma
 * @date 2020-9-27
 */
public enum ResultCode {
    SUCCESS(HttpStatus.OK, "操作成功"),
    FAILURE(HttpStatus.BAD_REQUEST, "操作失败"),
    VALIDATE_FAILURE(HttpStatus.BAD_REQUEST, 900, "请求参数异常"),
    UNAUTHORIZED(HttpStatus.UNAUTHORIZED, "未登录或token已经过期"),
    FORBIDDEN(HttpStatus.FORBIDDEN, "没有相关权限"),
    NOT_FOUND(HttpStatus.NOT_FOUND, "地址不存在"),
    SYSTEM_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "操作失败");

    private final HttpStatus status;
    private final int        code;
    private final String     message;

    private ResultCode(HttpStatus status, int code, String message) {
        this.status = status;
        this.code = code;
        this.message = message;
    }

    ResultCode(HttpStatus status, String message) {
        this.status = status;
        this.code = status.value();
        this.message = message;
    }

    public HttpStatus getStatus() {
        return status;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }
}
